AppleScript のサンプル
この AppleScript は、コンピュータのグループの高速クリーンアップを実行するために使用できます。このスクリプトはまず、干渉を防ぐためにコンピュータ画面をロックします。次に、クライアントコンピュータの現在アクティブなデスクトップ上に残っているすべての項目を削除します。最後に、クライアントの「ゴミ箱」を空にし、画面をロック解除して作業を完了します。
このスクリプトは学習目的で作成されたものであり、コンピューティング環境への適合性については明示、暗示を問わず保証されていません。また、このサンプルスクリプトは対象コンピュータ上の項目を削除します。各自の責任のもとで使用してください。
- -- 「Remote Desktop」のローカルコピーのコマンド操作を開始する
- tell application "Remote Desktop"
- -- 実行対象のリストを決定する。この場合は「Classroom」という名前のリスト
- set these_computers to computer list "Classroom"
- -- ロックされた画面に表示するテキストを決定する
- set screen_message to "Please wait" as Unicode text
- -- リモートコンピュータ上で AppleScript を実行する UNIX スクリプトを作成する
- set the UNIX_script to "osascript -e 'tell application \"Finder\" to delete every item of the desktop whose class is not disk'"
- -- ロックタスクのパラメータを設定する
- set lock_task to make new lock screen task with properties {name:"Lock Classroom", message:screen_message}
- -- タスクを実行する
- execute lock_task on these_computers
- -- UNIX スクリプトパラメータを設定する
- set clean_task to make new send unix command task with properties {name:"Clean Desktop", showing output:false, script:UNIX_script}
- -- タスクを実行する
- execute clean_task on these_computers
- -- その後、「ゴミ箱」を空にする
- execute (make new empty trash task) on these_computers
- -- 終了したら画面のロックを解除する
- execute (make new unlock screen task) on these_computers
- end tell
- tell application "Remote Desktop"
関連トピック: